package com.doubao.doubao.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doubao.doubao.common.api.ApiResult;
import com.doubao.doubao.model.entity.UmsUser;
import com.doubao.doubao.model.vo.PostVO;
import com.doubao.doubao.service.IBmsPostService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/search")
public class BmsSearchController extends BaseController {

    @Resource
    private IBmsPostService postService;

    @GetMapping
    public ApiResult<Page<PostVO>> searchList(@RequestParam("keyword") String keyword,
                                              @RequestParam("pageNum") Integer pageNum,
                                              @RequestParam("pageSize") Integer pageSize) {
        Page<PostVO> results = postService.searchByKey(keyword, new Page<>(pageNum, pageSize));
        return ApiResult.success(results);
    }





//    @GetMapping("/getSearch")
//    public ApiResult<Page<PostVO>> getsearchList(@RequestParam(value = "keyword", defaultValue = "") String keyword,
//                                              @RequestParam("pageNum") Integer pageNum,
//                                              @RequestParam("pageSize") Integer pageSize) {
//        Page<PostVO> results = postService.searchByKey(keyword, new Page<>(pageNum, pageSize));
//        return ApiResult.success(results);
//    }



}
